package com.aigou.admin.service.impl;

import com.aigou.admin.dao.Receiving_addressDAO;
import com.aigou.admin.dao.impl.Receiving_addressDAOImpl;
import com.aigou.admin.entity.PageEntity;
import com.aigou.admin.entity.Receiving_address;
import com.aigou.admin.service.Receiving_addressservice;

import java.util.List;

public class Receiving_addressserviceImpl implements Receiving_addressservice {
    private Receiving_addressDAO receiving_addressDAO = new Receiving_addressDAOImpl();

    @Override
    public PageEntity<Receiving_address> findReceiving_addressPage(Integer current, Integer pageSize) {
        int total = receiving_addressDAO.selectreceiving_addressCount();
        List<Receiving_address> receiving_addresses = receiving_addressDAO.receiving_addressLimit((current - 1) * pageSize,pageSize);
        PageEntity<Receiving_address> pageEntity = new PageEntity<>();
        pageEntity.setCurrent(current);
        pageEntity.setPageSize(pageSize);
        pageEntity.setTotal(total);
        pageEntity.setRecords(receiving_addresses);
        return pageEntity;
    }

    @Override
    public List<Receiving_address> findAll() {
        return receiving_addressDAO.setAll();
    }

    @Override
    public Receiving_address findByid(String id) {
        return receiving_addressDAO.selectById(id);
    }

    @Override
    public boolean save(Receiving_address receiving_address) {
        return receiving_addressDAO.inser(receiving_address);
    }

    @Override
    public boolean delete(String id) {
        return receiving_addressDAO.delete(id);
    }

    @Override
    public boolean update(Receiving_address receiving_address) {
        return receiving_addressDAO.update(receiving_address);
    }
}
